package com.cc.enterprise.model;

import com.cc.enterprise.validate.ValidationGroup1;
import com.cc.enterprise.validate.ValidationGroup2;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.*;

@ApiModel(value = "用户实体类", description = "用户信息描述类")
@Data
public class User {
    private Integer id;
    //    @Size(min = 5, max = 10, message = "{user.username.size}")
    @Size(min = 5, max = 10, message = "{user.name.size}", groups = ValidationGroup1.class)
    @ApiModelProperty(value = "用户名")
    private String username;

    //    @NotNull(message = "{user.address.notnull}")
    @NotNull(message = "{user.address.notnull}", groups = ValidationGroup2.class)
    @ApiModelProperty(value = "用户地址")
    private String address;
    private String gender;

    @DecimalMin(value = "1", message = "{user.age.size}")
    @DecimalMax(value = "200", message = "{user.age.size}")
    private Integer age;

    @Email(message = "{user.email.pattern}")
//    @NotNull(message = "{user.email.notnull}")
    @NotNull(message = "{user.email.notnull}", groups = {ValidationGroup1.class,
            ValidationGroup2.class})
    private String email;
    //省略 getter/setter
}